package com.meitianhui.convenitenbuy.util;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

import static com.meitianhui.convenitenbuy.util.BtnMenuDialogResourceUtil.mContext;

/**
 * Created by Administrator on 2017/11/2.
 */

public class PixelUtils {

    public static int dip2px(float dipValue) {
        DisplayMetrics dm = getDisPlayMetrics();
        return (int)(dipValue * dm.density + 0.5F);
    }

    public static DisplayMetrics getDisPlayMetrics() {
        Display display = getDisplay();
        DisplayMetrics dm = new DisplayMetrics();
        display.getMetrics(dm);
        return dm;
    }

    public static int getScreenDpi() {
        DisplayMetrics dm = getDisPlayMetrics();
        return dm.densityDpi;
    }

    public static Display getDisplay() {
        Display display = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        return display;
    }


}
